home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / pc / software / entwickl / macos / ingwdef.hqx / IngisWDEF 1.2 ƒ / IngisWDEF.p < prev    next >
Text File  |  1996-08-18  |  19KB  |  542 lines

  1. { *** Main unit for the "IngisWDEF" WDEF building package *** }
  2.  
  3. {© 1994-1995 by Ingemar Ragnemalm}
  4. {You may use it freely as long as credits are given in the final program.}
  5.  
  6.  
  7. {***  IngisWDEF  ***}
  8. {}
  9. {Version 1.0}
  10. {}
  11. {This WDEF is written in order to be as easily customized as possible, in order to produce new}
  12. {interesting WDEFs. The code consists of two parts, IngisWDEF.p and CustomStubs.p. The idea is}
  13. {to separate code that must be changed from code that can remain the same.}
  14. {}
  15. {The code in IngisWDEF will seldom have to be modified when making a new WDEF.}
  16. {}
  17. {CustomStub (which should come in two versions, one with sample code and one with empty stubs)}
  18. {is where your code goes. You create a grow region, a close box, draw the drag bar and create the}
  19. {contents and drag regions.}
  20. {}
  21. {An important point with IngisWDEF is that it uses regions rather than rectangles wherever possible.}
  22. {This makes it very easy to modify it for making windows with non-rectangular shapes. Few other}
  23. {WDEF samples do that - surprisingly few! Also, I have seen only a single WDEF that allowed}
  24. {resizing with color windows, and that was rectangular.}
  25. {}
  26. {BTW, I found the best way to develop a WDEF with Think Pascal: use a working application (small -}
  27. {Skel is perfect) as its resource file! The application should be configured to use our WDEF for one}
  28. {window. That way, "build code resource" makes a copy of that application with our WDEF in it.}
  29. {Build, switch to Finder and run. Simple! Who needs a special "WDEF tester"? (OK, perhaps for}
  30. {changing the variant code.)}
  31. {}
  32. {What is still missing? Separate handling of parts in different screens?}
  33. {Close box is assumed to be rectangular - could perhaps be generalized. Lots and lots of out of}
  34. {memory checks! (All those regions that can take our last byte!) Better rules for deciding color/BW.}
  35. {Standard colors from the appropriate resource instead of the standard blue tint. Better routine}
  36. {and variable names.}
  37. {}
  38. {ASSUMPTIONS that are not necessarily right:}
  39. {- Close/zoom boxes always rectangular and only one of each.}
  40. {- All the window is contents, drag area, frame or shadow - no "dead" parts.}
  41.  
  42.  
  43. unit IngisWDEF;
  44.  
  45. interface
  46.     uses
  47. {$IFC UNDEFINED THINK_PASCAL}
  48.         Types, QuickDraw, ToolUtils, Windows, Events, Memory, OSUtils,
  49. {$ENDC}
  50.         CustomStubs, IngisWDEFUtils;
  51.  
  52. {$MAIN}
  53.     function main (varCode: integer; macWindow: WindowPtr; theMessage: integer; param: longint): longint;
  54.  
  55. implementation
  56.  
  57.     type
  58.         RectPtr = ^Rect; {For passing the parameter to DrawGrow}
  59.  
  60. {******************************************************}
  61. { GetDragBar                                                                                    }
  62. {                                                                                                }
  63. {        Pass back a region which encloses the drag bar of the window                    }
  64. { Note: dragRgn must already be initialized!                                                 }
  65. { You can probably leave this routine without change!                                        }
  66. { We assume that the contRgn minus the strucRgn, frame and shadow is the dragRgn!}
  67. { *****************************************************}
  68.  
  69.     procedure GetDragBar (varCode: integer; macWindow: WindowPeek; var dragRgn: RgnHandle);
  70.         var
  71.             radius: integer;
  72.             dragBar: Rect;
  73.     begin
  74.         CopyRgn(macWindow^.strucRgn, dragRgn);
  75.         OffsetRgn(dragRgn, -kShadowLength, -kShadowLength);
  76.         SectRgn(dragRgn, macWindow^.strucRgn, dragRgn);
  77.         DiffRgn(dragRgn, macWindow^.contRgn, dragRgn);
  78.         InsetRgn(dragRgn, kFrameWidth, kFrameWidth);
  79.     end;
  80.  
  81.  
  82. {*****************************************************************************}
  83. { DrawFrame}
  84. {}
  85. {        Draw the entire window frame. Calls several custom routines!}
  86. { *****************************************************************************}
  87.  
  88.     procedure DrawFrame (varCode: integer; macWindow: WindowPeek);
  89.         var
  90.             wFrame: Rect;                { Window frame around content rgn    }
  91.  
  92.             wFrameRgn: RgnHandle;
  93.             tmpPt: Point;
  94.             dragBar: RgnHandle;            { Drag bar of window                }
  95.             savePen: PenState;            { Current pen characteristics        }
  96.             saveForeColor, saveBackColor: RGBColor;
  97.             colorFlag: Boolean;
  98.             closeBox, zoomBox: Rect;
  99.     begin
  100.         SaveColors(saveForeColor, saveBackColor);
  101.         GetPenState(savePen);                { Save the current pen state        }
  102.  
  103.         { Structure region of a window has four parts:    }
  104.         {        (1) Frame around the content region        }
  105.         {        (2) Drop shadow                            }
  106.         {        (3) Drag bar                            }
  107.         {        (4) Close box inside the drag bar        }
  108.  
  109.                 { (1) Frame around content region    }
  110.         wFrameRgn := NewRgn;
  111.         CopyRgn(macWindow^.contRgn, wFrameRgn);
  112.         InsetRgn(wFrameRgn, -kFrameWidth, -kFrameWidth);
  113.         PenSize(kFrameWidth, kFrameWidth);
  114.         FrameRgn(wFrameRgn);
  115. {DisposeRgn(wFrameRgn); Not yet- we'll reuse it}
  116.  
  117.                 { (2) Drop shadow below and to the    right of content region        }
  118.         PenSize(kShadowLength, kShadowLength);
  119.  
  120.         CopyRgn(macWindow^.strucRgn, wFrameRgn);
  121.         OffsetRgn(wFrameRgn, -kShadowLength, -kShadowLength);
  122.         DiffRgn(macWindow^.strucRgn, wFrameRgn, wFrameRgn);
  123.         ForeColor(blackColor);
  124.         PaintRgn(wFrameRgn);
  125.         DisposeRgn(wFrameRgn);
  126.  
  127.         dragBar := NewRgn;
  128.         GetDragBar(varCode, macWindow, dragBar);
  129.  
  130.         colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  131.         if colorFlag then
  132.             colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  133.         DrawDragBar(varCode, macWindow, dragBar, colorFlag);
  134.  
  135.         DefaultColors;
  136.  
  137.         if macWindow^.hilited then
  138.             if macWindow^.goAwayFlag then
  139.                 begin        { Make sure window has a close box    }
  140.                     GetCloseBox(varCode, dragBar, closeBox);
  141.                     DrawCloseBox(varCode, macWindow, closeBox, colorFlag);
  142.                 end;
  143.         if macWindow^.hilited then
  144.             if macWindow^.spareFlag then
  145.                 begin        { Make sure window has a zoom box    }
  146.                     GetZoomBox(varCode, dragBar, zoomBox);
  147.                     DrawZoomBox(varCode, macWindow, zoomBox, colorFlag);
  148.                 end;
  149.  
  150.         InsetRgn(dragBar, -kFrameWidth, -kFrameWidth);
  151.         PenSize(kFrameWidth, kFrameWidth);
  152.         DefaultColors;
  153.         FrameRgn(dragBar);
  154.         DisposeRgn(dragBar);
  155.  
  156.         SetPenState(savePen);                { Restore original pen state        }
  157.         RestoreColors(saveForeColor, saveBackColor);
  158.     end;
  159.  
  160.  
  161. {*****************************************************************************}
  162. { DoToggleCloseBox}
  163. {}
  164. {        Toggle hiliting of the close box.}
  165. { *****************************************************************************}
  166.  
  167.     procedure DoToggleCloseBox (varCode: integer; macWindow: WindowPeek);
  168.         var
  169.             dragBar: RgnHandle;                { Rectangle enclosing drag bar        }
  170.             closeBox: Rect;                { Rectangle enclosing close box    }
  171.             colorFlag: Boolean;
  172.             saveForeColor, saveBackColor: RGBColor;
  173.             pt: Point;
  174.     begin
  175.         dragBar := NewRgn;
  176.         GetDragBar(varCode, macWindow, dragBar);
  177.         SetRect(closeBox, 0, 0, 0, 0); {If GetCloseBox does nothing, we want an empty rect.}
  178.         if macWindow^.goAwayFlag then
  179.             begin
  180.                 GetCloseBox(varCode, dragBar, closeBox);
  181.  
  182.                 colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  183.                 if colorFlag then
  184.                     colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  185.  
  186.                 GetMouse(pt); {Get a point for PtInRect}
  187.                 if colorFlag then
  188.                     SaveColors(saveForeColor, saveBackColor);
  189.                 if PtInRect(pt, closeBox) and Button then
  190.                     DrawHitCloseBox(varCode, macWindow, closeBox, colorFlag)
  191.                 else
  192.                     DrawCloseBox(varCode, macWindow, closeBox, colorFlag);
  193.                 if colorFlag then
  194.                     RestoreColors(saveForeColor, saveBackColor);
  195.             end;
  196.         DisposeRgn(dragBar);
  197.     end; {DoToggleCloseBox}
  198.  
  199. { Same as above, but for the zoom box! }
  200.     procedure DoToggleZoomBox (varCode: integer; macWindow: WindowPeek);
  201.         var
  202.             dragBar: RgnHandle;                { Rectangle enclosing drag bar        }
  203.             zoomBox: Rect;                { Rectangle enclosing close box    }
  204.             colorFlag: Boolean;
  205.             saveForeColor, saveBackColor: RGBColor;
  206.             pt: Point;
  207.     begin
  208.         dragBar := NewRgn;
  209.         GetDragBar(varCode, macWindow, dragBar);
  210.         SetRect(zoomBox, 0, 0, 0, 0); {If GetZoomBox does nothing, we want an empty rect.}
  211.         if macWindow^.spareFlag then
  212.             begin
  213.                 GetZoomBox(varCode, dragBar, zoomBox);
  214.  
  215.                 colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  216.                 if colorFlag then
  217.                     colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  218.  
  219.                 GetMouse(pt); {Get a point for PtInRect}
  220.                 if colorFlag then
  221.                     SaveColors(saveForeColor, saveBackColor);
  222.                 if PtInRect(pt, zoomBox) and Button then
  223.                     DrawHitZoomBox(varCode, macWindow, zoomBox, colorFlag)
  224.                 else
  225.                     DrawZoomBox(varCode, macWindow, zoomBox, colorFlag);
  226.                 if colorFlag then
  227.                     RestoreColors(saveForeColor, saveBackColor);
  228.             end;
  229.         DisposeRgn(dragBar);
  230.     end; {DoToggleZoomBox}
  231.  
  232.  
  233. {A little padding around LocalToGlobal.}
  234.     procedure MyLocalToGlobal (macWindow: univ WindowPtr; var p: Point);
  235.         var
  236.             savePort: GrafPtr;
  237.     begin
  238.         GetPort(savePort);
  239.         SetPort(macWindow);
  240.         LocalToGlobal(p);
  241.         SetPort(savePort);
  242.     end;
  243.  
  244.  
  245. {*****************************************************************************}
  246. { FindPart}
  247. {}
  248. {        Find which part of the window was hit by a mouse click at the}
  249. {        specified location.}
  250. { *****************************************************************************}
  251.  
  252.     function FindPart (varCode: integer; macWindow: WindowPeek; location: longint): integer;
  253.         var
  254.             theClick: Point;                { Global coords of mouse click        }
  255.             dragBar, growRgn: RgnHandle;
  256.             closeBox, zoomBox, portR: Rect;
  257.     begin
  258.         theClick.h := LoWord(location);        { Extract horizontal component        }
  259.         theClick.v := HiWord(location);        { Extract vertical component        }
  260.  
  261. { Are we inside the window structure at all?}
  262.         if not PtInRgn(theClick, macWindow^.strucRgn) then
  263.             begin
  264.                 FindPart := wNoHit;
  265.                 Exit(FindPart);
  266.             end;
  267.  
  268. {Must check grow before contRgn, since grow is (often) a part of the contRgn.}
  269.         growRgn := NewRgn;
  270.         GetGrowRgn(varCode, macWindow, growRgn);
  271.         if PtInRgn(theClick, growRgn) then
  272.             begin
  273.                 FindPart := wInGrow;
  274.                 DisposeRgn(growRgn);
  275.                 exit(FindPart);
  276.             end;
  277.         DisposeRgn(growRgn);
  278.  
  279.         if PtInRgn(theClick, macWindow^.contRgn) then
  280.             begin
  281.                 FindPart := wInContent;                { Content region    }
  282.                 Exit(FindPart);
  283.             end;
  284.  
  285.         dragBar := NewRgn;
  286.                                             { Drag bar?    }
  287.         GetDragBar(varCode, macWindow, dragBar);
  288.         if PtInRgn(theClick, dragBar) then
  289.             begin                            { Drag bar or close box! }
  290.                 SetRect(closeBox, 0, 0, 0, 0); {If GetCloseBox does nothing, we want an empty rect.}
  291.                 if macWindow^.goAwayFlag then
  292.                     GetCloseBox(varCode, dragBar, closeBox);
  293.                 SetRect(zoomBox, 0, 0, 0, 0); {If GetZoomBox does nothing, we want an empty rect.}
  294.                 if macWindow^.spareFlag then
  295.                     GetZoomBox(varCode, dragBar, zoomBox);
  296.                 if macWindow^.goAwayFlag and PtInRect(theClick, closeBox) then
  297.                     FindPart := wInGoAway        { Close box! }
  298.                 else if macWindow^.spareFlag and PtInRect(theClick, zoomBox) then
  299.                     begin
  300. {Compare the size of portRect with stdState!}
  301.                         portR := macWindow^.port.portRect;
  302.                         with WStateDataHandle(macWindow^.dataHandle)^^ do
  303.                             if ((portR.right - portR.left) = (stdState.right - stdState.left)) and ((portR.bottom - portR.top) = (stdState.bottom - stdState.top)) then
  304.                                 begin
  305.                                     FindPart := wInZoomIn;
  306.                                 end
  307.                             else
  308.                                 begin {Not match - save the portRect as the userState}
  309.                                     FindPart := wInZoomOut;
  310.                                     MyLocalToGlobal(macWindow, portR.topLeft);
  311.                                     MyLocalToGlobal(macWindow, portR.botRight);
  312.                                     WStateDataHandle(macWindow^.dataHandle)^^.userState := portR;
  313.                                 end;
  314.                     end
  315.                 else
  316.                     FindPart := wInDrag;            { Drag bar and NOT close box! }
  317.             end
  318.         else
  319.             FindPart := wNoHit;            { Click somewhere else. Don't bother. }
  320.         DisposeRgn(dragBar);
  321.     end;
  322.  
  323. {*****************************************************************************}
  324. { BuildRegions}
  325. {}
  326. {        Build the structure and content region of a window.}
  327. { *****************************************************************************}
  328.  
  329.     procedure BuildRegions (varCode: integer; macWindow: WindowPeek);
  330.         var
  331.             theRect: Rect;            { Window regions are rectangular    }
  332.             theRgn: RgnHandle;        { Region defining drop shadow - and everything else we need a temprary region for        }
  333.     begin
  334. {The content region should be calculated from the port rectangle - but, of course, does not}
  335. {have to be idenntical to it.}
  336.  
  337. {Init the region.}
  338.         theRgn := NewRgn;                { Define region for the shadow        }
  339.  
  340.         theRect := macWindow^.port.portRect;
  341.  
  342.         MyLocalToGlobal(macWindow, theRect.topLeft);
  343.         MyLocalToGlobal(macWindow, theRect.botRight);
  344. {Varför funkade detta:???}
  345. {OffsetRect(theRect, -macWindow^.port.portBits.bounds.left, -macWindow^.port.portBits.bounds.top);{}
  346.  
  347. {CUSTOM: Given the varCode and rectangle, create contRgn and dragRgn (returned in strucRgn)!}
  348.         BuildCustomRegions(varCode, theRect, macWindow^.contRgn, macWindow^.strucRgn);
  349.  
  350. {Build struc, add frame and shadow:}
  351.  
  352. {struc := cont + drag}
  353.         UnionRgn(macWindow^.contRgn, macWindow^.strucRgn, macWindow^.strucRgn);
  354. {Expand struc to include frame}
  355.         InsetRgn(macWindow^.strucRgn, -kFrameWidth, -kFrameWidth);
  356. {Make a copy}
  357.         CopyRgn(macWindow^.strucRgn, theRgn);
  358. {Offset it for the shadow}
  359.         OffsetRgn(theRgn, kShadowLength, kShadowLength);
  360. {struc := struc + shadow}
  361.         UnionRgn(macWindow^.strucRgn, theRgn, macWindow^.strucRgn);
  362.  
  363.         DisposeRgn(theRgn);        { All thru with region    }
  364.     end;
  365.  
  366.  
  367. {*****************************************************************************}
  368. { DrawGrowFrame - Drawing the frame during window resizing. }
  369. { *****************************************************************************}
  370.  
  371.     procedure DrawGrowFrame (varCode: integer; macWindow: WindowPeek; theRect: Rect);
  372.         var
  373.             tmpContRgn, tmpDragRgn: RgnHandle;
  374.             saveForeColor, saveBackColor: RGBColor;
  375.     begin
  376.         SaveColors(saveForeColor, saveBackColor);
  377.         with theRect do
  378.             begin
  379.                 if right - left < kMinWidth then
  380.                     right := left + kMinWidth;
  381.                 if bottom - top < kMinHeight then
  382.                     bottom := top + kMinHeight;
  383.             end;
  384.  
  385.         tmpContRgn := NewRgn;
  386.         tmpDragRgn := NewRgn;
  387.         BuildCustomRegions(varCode, theRect, tmpContRgn, tmpDragRgn);
  388.         InsetRgn(tmpContRgn, -kFrameWidth, -kFrameWidth);
  389.         InsetRgn(tmpDragRgn, -kFrameWidth, -kFrameWidth);
  390.         FrameRgn(tmpContRgn);
  391.         FrameRgn(tmpDragRgn);
  392.         DisposeRgn(tmpContRgn);
  393.         DisposeRgn(tmpDragRgn);
  394. {The above is well enough, but we also provide a stub for some extra:}
  395.         DrawScrollFrame(varCode, macWindow, theRect);
  396.         RestoreColors(saveForeColor, saveBackColor);
  397.     end;
  398.  
  399. {*****************************************************************************}
  400. { PrepareGrowIcon - Sets up for the custom routine that draws the grow icon. }
  401. {*****************************************************************************}
  402.  
  403.     procedure PrepareGrowIcon (varCode: integer; macWindow: WindowPeek; theRect: Rect);
  404.         var
  405.             tmpRect, smallRect, largeRect: Rect;
  406.         var
  407.             tempClip, saveClip, growRgn: RgnHandle;
  408.             savePort: GrafPtr;
  409.             saveForeColor, saveBackColor: RGBColor;
  410.             colorFlag: Boolean;
  411.     begin
  412.         SaveColors(saveForeColor, saveBackColor);
  413.         theRect := macWindow^.port.portRect;
  414.         MyLocalToGlobal(macWindow, theRect.topLeft);
  415.         MyLocalToGlobal(macWindow, theRect.botRight);
  416.  
  417.         tempClip := NewRgn;
  418.         saveClip := NewRgn;
  419.         growRgn := NewRgn;
  420.  
  421.         GetGrowRgn(varCode, macWindow, growRgn);
  422.  
  423.         SectRgn(macWindow^.port.visRgn, macWindow^.port.clipRgn, tempClip);
  424.         GetClip(saveClip);
  425.         OffsetRgn(tempClip, -macWindow^.port.portRect.left + theRect.left, -macWindow^.port.portRect.top + theRect.top);
  426.         SetClip(tempClip);
  427.  
  428.         DrawScrollFrame(varCode, macWindow, theRect); {Standard eller fritt val?}
  429.         DefaultColors;
  430.  
  431.         colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  432.         if colorFlag then
  433.             colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  434.  
  435.         DrawTheGrowIcon(varCode, WindowPeek(macWindow), theRect, growRgn, colorFlag);
  436.  
  437.         RestoreColors(saveForeColor, saveBackColor);
  438.         SetClip(saveClip);
  439.         DisposeRgn(saveClip);
  440.         DisposeRgn(tempClip);
  441.         DisposeRgn(growRgn);
  442.     end;
  443.  
  444.  
  445. {*****************************************************************************}
  446. { SyncPorts - the ugly patch for making it work with Color QD. ONLY called when CQD i available! }
  447. { *****************************************************************************}
  448.  
  449.     procedure SyncPorts;
  450.         var
  451.             bwPort: GrafPtr;
  452.             colorPort: CGrafPtr;
  453.     begin
  454.         GetWMgrPort(bwPort);
  455.         GetCWMgrPort(colorPort);
  456.         SetPort(GrafPtr(colorPort));
  457. {Copy some fields:}
  458.         BlockMove(@bwPort^.pnLoc, @colorPort^.pnLoc, 10);
  459.         BlockMove(@bwPort^.pnVis, @colorPort^.pnVis, 14);
  460.         PenPat(bwPort^.pnPat);
  461.         BackPat(bwPort^.bkPat);
  462.     end;
  463.  
  464.  
  465. {*****************************************************************************}
  466. { Main Function}
  467. { *****************************************************************************}
  468.  
  469. {$MAIN}
  470.     function main (varCode: integer; macWindow: WindowPtr; theMessage: integer; param: longint): longint;
  471.         var
  472.             needSyncPorts: Boolean;
  473.             savePort: GrafPtr;
  474.             theRect: Rect;
  475.     begin
  476.         main := 0;
  477.  
  478. {A trick from InfinityWindoid:}
  479.         needSyncPorts := ((theMessage = wDraw) or (theMessage = wHit) or (theMessage = wGrow) or (theMessage = wDrawGIcon)) and HasCQDraw;
  480.         if needSyncPorts then
  481.             begin
  482.                 GetPort(savePort);
  483.                 SyncPorts;
  484.             end;
  485.  
  486.         case theMessage of                { Take appropriate action            }
  487.  
  488.             wNew: 
  489.                 begin
  490.                     if WindowPeek(macWindow)^.dataHandle = nil then
  491.                         WindowPeek(macWindow)^.dataHandle := NewHandle(Sizeof(WStateData));
  492.                     with WStateDataHandle(WindowPeek(macWindow)^.dataHandle)^^ do
  493.                         begin
  494.                             stdState := macWindow^.portRect;
  495.                             MyLocalToGlobal(macWindow, stdState.topLeft);
  496.                             MyLocalToGlobal(macWindow, stdState.botRight);
  497.                             userState := stdState;
  498.                         end;
  499.                     InitMyWindow(varCode, WindowPeek(macWindow));
  500.                 end;
  501.             wDispose: 
  502.                 begin
  503.                     if WindowPeek(macWindow)^.dataHandle <> nil then
  504.                         DisposeHandle(WindowPeek(macWindow)^.dataHandle);
  505.                     WindowPeek(macWindow)^.dataHandle := nil;
  506.                     DisposeMyWindow(varCode, WindowPeek(macWindow));
  507.                 end;
  508.  
  509.             wDraw:                        { Draw the window frame            }
  510.  
  511.                 if WindowPeek(macWindow)^.visible then     { Only draw if window is visible    }
  512.                     case integer(param) of    { Find out which part to draw        }
  513.  
  514.                         wNoHit:        { Draw the entire frame            }
  515.                             DrawFrame(varCode, WindowPeek(macWindow));
  516.  
  517.                         wInGoAway:        { Toggle hiliting of the close box    }
  518.                             DoToggleCloseBox(varCode, WindowPeek(macWindow));
  519.  
  520.                         wInZoomIn, wInZoomOut:        { Toggle hiliting of the close box    }
  521.                             DoToggleZoomBox(varCode, WindowPeek(macWindow));
  522.                     end;
  523.  
  524.             wHit:                        { Find part of window clicked in    }
  525.                 main := FindPart(varCode, WindowPeek(macWindow), param);
  526.  
  527.             wCalcRgns:                    { Build structure & content rgns    }
  528.                 BuildRegions(varCode, WindowPeek(macWindow));
  529.  
  530.             wGrow: 
  531.                 DrawGrowFrame(varCode, WindowPeek(macWindow), RectPtr(param)^);
  532.  
  533.             wDrawGIcon: 
  534.                 PrepareGrowIcon(varCode, WindowPeek(macWindow), theRect); {Set up and calls DrawTheGrowIcon}
  535.         end; {case}
  536.  
  537.         if needSyncPorts then {Oh, how I hate those afterthoughts and undocumented tricks!!!}
  538.             SetPort(savePort);
  539.  
  540.     end; {main}
  541.  
  542. end.